#include <stdio.h>

int main(int argc, char const *argv[])
{
    char input[2048], *p;
    int counts[26] = { 0 }, i, h, w, x, y;

    //统计字符
    for (i = 0; i < 4; i++)
    {
        p = gets(input);
        while (*p)
        {
            if (*p >= 'A' && *p <= 'Z')
            {
                counts[*p - 'A']++;
            }
            p++;
        }
    }

    //获取高度
    h = 0;
    for (i = 0; i < 26; i++)
        h = counts[i] > h ? counts[i] : h;
    //绘制*号
    for (y = 0; y < h; y++)
    {
        w = 25;
        while (counts[w] < h - y)
            w--;
        
        for (x = 0; x < w; x++)
        {
            printf("%c ", (counts[x] >= h - y) ? '*' : ' ');
        }
        printf("*\n");
    }
    
    for (i = 0; i < 25; i++)
    {
        printf("%c ", 'A' + i);
    }
    printf("Z");

    return 0;
}
